package com.boot.schedule;

import org.apache.http.client.utils.DateUtils;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author songyake
 * @Date: 2023/04/10
 */
@EnableScheduling
@Component
public class ScheduledTest1 {

//    @Scheduled(fixedDelay = 3000)
    public void schedule1() throws InterruptedException {
        System.out.println("schedule11-" + DateUtils.formatDate(new Date()) + " threadName-" + Thread.currentThread().getName());
        Thread.sleep(60000);
        int i = 1/0;
    }

//    @Scheduled(cron = "0/2 * * * * ?")
//    public void schedule2(){
//        System.out.println("schedule22-" + DateUtils.formatDate(new Date()) + " threadName-" + Thread.currentThread().getName());
//    }
//
//    @Scheduled(cron = "0/2 * * * * ?")
//    public void schedule3(){
//        System.out.println("schedule33-" + DateUtils.formatDate(new Date()) + " threadName-" + Thread.currentThread().getName());
//    }
}
